import request from '@/utils/request'

// 发送验证码
export function sendCode(email) {
  return request({
    url: '/user/sendCode',
    method: 'post',
    data: { email }
  })
}

// 邮箱登录
export function emailLogin(data) {
  return request({
    url: '/user/emailLogin',
    method: 'get',
    params: data  // 修改这里，将data改为params
  })
}

// 获取用户信息
export function getUserInfoService() {
  return request({
    url: '/user/info',
    method: 'get'
  })
}

// 退出登录
export function logoutService() {
  return request({
    url: '/user/logout',
    method: 'delete'  // 将method从'post'改为'delete'
  })
}

export function updateHeadImageService(params = {}) {
  return request({
    url: "/user/head-image/update",
    method: "put",
    data: params,
  });
}

export function editUserService(params = {}) {
  return request({
    url: "/user/edit",
    method: "put",
    data: params,
  });
}

export function getUserDetailService(userId) {
  return request({
    url: "/user/detail",
    method: "get",
    params: { userId },
  });
}

export function userSubmitService(data) {
  return request({
    url: "/user/question/rabbit/submit",
    method: "post",
    data,
  });
}
